<!--
 * @Description: 
 * @Author: rendc
 * @Date: 2025-11-04 14:53:07
 * @LastEditors: rendc
 * @LastEditTime: 2025-11-04 15:00:35
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <a href="http://www.baidu.com">跳转</a>
  <form action="./1-HTML事件处理程序.html">
  <button id="btn">提交按钮</button>
  </form>
  <script>
  var a = document.getElementsByTagName('a')[0];
  var btn = document.getElementById('btn');
  a.onclick = function (e) {
    // alert(1);
    // 阻⽌事件默认⾏为
    e.preventDefault();
  }
  btn.onclick = function (event) {
  // 阻⽌事件默认⾏为
    event.preventDefault();
  }
  window.onload = function () {
    console.log('onload');
  }
  
</script>
</body>
</html>